/**
 * Created by saber on 15/8/28.
 */

wcApp.controller('describeCtrl', ['$scope', '$state', 'ionicMaterialInk', 'ionicMaterialMotion','$http','$timeout','user','request','$rootScope',
    function ($scope, $state, ionicMaterialInk, ionicMaterialMotion,$http,$timeout,user,request,$rootScope) {
        $scope.userdata=user.data();
        $scope.request=request;

        $scope.pgCtrl={
            disable:false
            };

        $timeout(function() {
            ionicMaterialMotion.slideUp({
                selector: '.slide-up'
            });
        }, 300);

        $timeout(function() {
            ionicMaterialMotion.fadeSlideInRight({
                startVelocity: 3000
            });
        }, 700);
        // Set Ink
        ionicMaterialInk.displayEffect();
        
        $scope.describeSubmit= function () {
            $scope.pgCtrl.disable=true;
            $http.post($rootScope.baseUrl+"/enroll/createRequest",{
                firstWish:request.firstWish,
                secondWish:request.secondWish,
                describe:request.describe
            })
                .success(function (res, code) {
                    if(res.code==200){
                        $state.go("app.success");
                    }else{
                        alert(req.code);
                        $scope.pgCtrl.disable=false;
                    }
                });
        }
    }]);